package System_code;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-07-26
 * Time: 22:37
 */
public class Demo7 {
    public static void main(String[] args) {
        Thread t=new Thread(new Runnable() {
            @Override
            public void run() {
                while(true){
                    System.out.println("hello thread");
                }
            }
        },"我的线程");
        t.setDaemon(true);//设置新线程为后台线程，但主线程结束后，新线程即使没执行完，也会被强制结束
        t.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
